<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>editer</title>


{load href="__libs__/jquery/jquery.min.js"/}
{load href="__libs__/amaze/css/amazeui.min.css"/}
{load href="__libs__/amaze/js/amazeui.min.js"/}
{load href="__libs__/layer/layer.js"/}
{load href="__libs__/layui/layui.js"/}
{load href="__libs__/layui/css/layui.css"/}

<link rel="stylesheet" href="/assets/libs/myeditor/css/editormd.css" />   
</head>
<script src='/assets/libs/myeditor/editormd.js'></script>
<script src="/assets/libs/myeditor/lib/marked.min.js"></script>
<script src="/assets/libs/myeditor/lib/prettify.min.js"></script>
<script src="/assets/libs/myeditor/lib/raphael.min.js"></script>
<script src="/assets/libs/myeditor/lib/underscore.min.js"></script>
<script src="/assets/libs/myeditor/lib/sequence-diagram.min.js"></script>
<script src="/assets/libs/myeditor/lib/flowchart.min.js"></script>


<style type="text/css">
    *{
        margin: 0;
        padding: 0;
    }
</style>
<body>

    <div style="width: 90%;height: 100%;margin:5px auto;">
         <p style="font-size: 16px;width: 100%;font-weight: bold;">常见问题：</p>
         <input type="text" id="question" class="layui-input" value="{$question}">
         
         <p style="font-size: 16px;width: 100%;font-weight: bold;margin-top: 20px;">解决回答：</p>
         <div id="a-editormd"  style="width: 100%;height:100px;margin :0px;padding: 0px;">
             <textarea class="editormd-markdown-textarea" name="test-editormd-markdown-doc" id="a_editormd" >{$answer}</textarea>
             <textarea class="editormd-html-textarea" name="editorhtml" id="a_editorhtml"></textarea>     
         </div>
        <select id="groupid" style="margin-top:30px;border: 1px solid #d6d6d6;padding: 5px;">
            {volist name='groups' id='group'}
            <option value="{$group.id}" {$group.id==$current_groupid?"selected":""}>{$group.groupname}</option>
            {/volist}
        </select>
        <div style="position: absolute;right:10px;bottom:-60px;">
              <button onclick="geton()" class="am-btn am-btn-success" style=''>提交</button>  
        </div> 
    </div>
    
 
</body>

<script>

     $(function () {
        testEditor = editormd("a-editormd", {
            width: "100%",
            height: 260,
            path: '/assets/libs/myeditor/lib/',
            codeFold: true,
            //syncScrolling : false,
            saveHTMLToTextarea: true,    // 保存 HTML 到 Textarea
            searchReplace: true,
            watch : true,                // 关闭实时预览
            htmlDecode: "style,script,iframe|on*",            // 开启 HTML 标签解析，为了安全性，默认不开启    
            //toolbar  : false,             //关闭工具栏
            //previewCodeHighlight : false, // 关闭预览 HTML 的代码块高亮，默认开启
            emoji: true,
            taskList: true,
            tocm: true,         // Using [TOCM]
            tex: true,                   // 开启科学公式TeX语言支持，默认关闭
            flowChart: true,             // 开启流程图支持，默认关闭
            sequenceDiagram: true,       // 开启时序/序列图支持，默认关闭,
            //dialogLockScreen : false,   // 设置弹出层对话框不锁屏，全局通用，默认为true
            //dialogShowMask : false,     // 设置弹出层对话框显示透明遮罩层，全局通用，默认为true
            //dialogDraggable : false,    // 设置弹出层对话框不可拖动，全局通用，默认为true
            //dialogMaskOpacity : 0.4,    // 设置透明遮罩层的透明度，全局通用，默认值为0.1
            //dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色，全局通用，默认为#fff
            imageUpload: true,
            imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
            imageUploadURL: "/admin/event/uploadimg",
            onload: function () {
                // console.log('onload', this);
                // this.fullscreen();
                // this.unwatch();
                // this.watch().fullscreen();
                // this.setMarkdown("#PHP");
                // this.width("100%");
                // this.height(480);
                // this.resize("100%", 640);
            }  
        });
    });



function geton(){
    var q =$("#question").val();
    var a =$("#a_editorhtml").val() || $("#a_editorhtml").text();
    var ra =$("#a_editormd").val();
    var qid ={$qid};
    var groupid = $("#groupid").val();
 
    if(q && a){
   
       $.ajax({
         url:'/admin/manager/addquestion',
         type:'post',
         data:{question:q,answer:a,answer_read:ra,qid:qid, groupid: groupid},
         success:function(res){

            if(res.code == 0){
                layer.msg(res.msg,{icon:1,end:function(){
                    parent.location.reload();
                }});
            }
         }
       });
    }else{
       layer.msg('数据不完整');
    }
}


</script>
</html>